package indi.kane.demandlist.service.impl;

import indi.kane.demandlist.dao.DemandMapper;
import indi.kane.demandlist.entity.Demand;
import indi.kane.demandlist.service.IDemandService;
import indi.kane.demandlist.vo.DemandStatusVo;
import indi.kane.demandlist.vo.ResultVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: DemandService
 * @Author: kane
 * @Date: 2020-05-08 11:03 上午
 * @Description:
 */
@Service
public class DemandService implements IDemandService {
    @Resource
    private DemandMapper demandMapper;

    @Override
    public ResultVo deleteByPrimaryKey(Integer id) {
        demandMapper.deleteByPrimaryKey(id);
        return ResultVo.success(ResultVo.SUCCESS);
    }

    @Override
    public ResultVo insert(Demand record) {
        demandMapper.insert(record);
        return ResultVo.success(ResultVo.SUCCESS);
    }

    @Override
    public ResultVo insertSelective(Demand record) {
        demandMapper.insertSelective(record);
        return ResultVo.success(ResultVo.SUCCESS);
    }

    @Override
    public ResultVo selectByPrimaryKey(Integer id) {
        Demand demand =  demandMapper.selectByPrimaryKey(id);
        return ResultVo.success(demand);
    }

    @Override
    public ResultVo updateByPrimaryKeySelective(Demand record) {
        demandMapper.updateByPrimaryKeySelective(record);
        return ResultVo.success(ResultVo.SUCCESS);
    }

    @Override
    public ResultVo updateByPrimaryKey(Demand record) {
        demandMapper.updateByPrimaryKey(record);
        return ResultVo.success(ResultVo.SUCCESS);
    }

    @Override
    public ResultVo loadAll() {
        List<Demand> demands = demandMapper.loadAll();
        return ResultVo.success(demands);
    }

    @Override
    public ResultVo summaryStatus() {
        List<DemandStatusVo> r = demandMapper.summaryStatus();
        return ResultVo.success(r);
    }

    @Override
    public ResultVo query(Demand record) {
        List<Demand> demands = demandMapper.query(record);
        return ResultVo.success(demands);
    }
}